package vip.xiaonuo.supplier.modular.finance.balancelog.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.supplier.modular.finance.balancelog.entity.SupplierBalanceLog;
import vip.xiaonuo.supplier.modular.finance.balancelog.param.SupplierBalanceLogAddParam;
import vip.xiaonuo.supplier.modular.finance.balancelog.param.SupplierBalanceLogEditParam;
import vip.xiaonuo.supplier.modular.finance.balancelog.param.SupplierBalanceLogIdParam;
import vip.xiaonuo.supplier.modular.finance.balancelog.param.SupplierBalanceLogPageParam;
import vip.xiaonuo.supplier.modular.finance.balancelog.service.SupplierBalanceLogService;

import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import java.util.List;

/**
 * 账户日志控制器
 *
 * @author Mr.wu
 * @date  2025/05/17 11:43
 */
@Tag(name = "账户日志控制器")
@RestController
@Validated
public class SupplierBalanceLogController {

    @Resource
    private SupplierBalanceLogService supplierBalanceLogService;

    /**
     * 获取账户日志分页
     *
     * @author Mr.wu
     * @date  2025/05/17 11:43
     */
    @Operation(summary = "获取账户日志分页")
    @SaCheckPermission("/supplier/finance/balancelog/page")
    @GetMapping("/supplier/finance/balancelog/page")
    public CommonResult<Page<SupplierBalanceLog>> page(SupplierBalanceLogPageParam supplierBalanceLogPageParam) {
        return CommonResult.data(supplierBalanceLogService.page(supplierBalanceLogPageParam));
    }

    /**
     * 添加账户日志
     *
     * @author Mr.wu
     * @date  2025/05/17 11:43
     */
    @Operation(summary = "添加账户日志")
    @CommonLog("添加账户日志")
    @SaCheckPermission("/supplier/finance/balancelog/add")
    @PostMapping("/supplier/finance/balancelog/add")
    public CommonResult<String> add(@RequestBody @Valid SupplierBalanceLogAddParam supplierBalanceLogAddParam) {
        supplierBalanceLogService.add(supplierBalanceLogAddParam);
        return CommonResult.ok();
    }

    /**
     * 编辑账户日志
     *
     * @author Mr.wu
     * @date  2025/05/17 11:43
     */
    @Operation(summary = "编辑账户日志")
    @CommonLog("编辑账户日志")
    @SaCheckPermission("/supplier/finance/balancelog/edit")
    @PostMapping("/supplier/finance/balancelog/edit")
    public CommonResult<String> edit(@RequestBody @Valid SupplierBalanceLogEditParam supplierBalanceLogEditParam) {
        supplierBalanceLogService.edit(supplierBalanceLogEditParam);
        return CommonResult.ok();
    }

    /**
     * 删除账户日志
     *
     * @author Mr.wu
     * @date  2025/05/17 11:43
     */
    @Operation(summary = "删除账户日志")
    @CommonLog("删除账户日志")
    @SaCheckPermission("/supplier/finance/balancelog/delete")
    @PostMapping("/supplier/finance/balancelog/delete")
    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
                                                   List<SupplierBalanceLogIdParam> supplierBalanceLogIdParamList) {
        supplierBalanceLogService.delete(supplierBalanceLogIdParamList);
        return CommonResult.ok();
    }

    /**
     * 获取账户日志详情
     *
     * @author Mr.wu
     * @date  2025/05/17 11:43
     */
    @Operation(summary = "获取账户日志详情")
    @SaCheckPermission("/supplier/finance/balancelog/detail")
    @GetMapping("/supplier/finance/balancelog/detail")
    public CommonResult<SupplierBalanceLog> detail(@Valid SupplierBalanceLogIdParam supplierBalanceLogIdParam) {
        return CommonResult.data(supplierBalanceLogService.detail(supplierBalanceLogIdParam));
    }
}
